bitkeeper revision 1.1189 (420d52d34bmxozCOzbUs5pmo2zfT-w)
authoriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>
Sat, 12 Feb 2005 00:50:27 +0000 (00:50 +0000)
committeriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>
Sat, 12 Feb 2005 00:50:27 +0000 (00:50 +0000)
Subject: [PATCH] xenctx.patch

Does this sound interesting? I found it useful to debug looping guests.
A gdb stub would be nicer - but this one is lighter weight.
        -Arun
Tool for dumping the cpu context
# xenctx 1 0
eip: c01dfeab   esp: c1603c98
eax: 00000020   ebx: c0432e10   ecx: 00000ee6   edx: 000001f7
esi: c0432d60   edi: 00000296   ebp: c0432d60
 cs: 00000060    ds: 00000068    fs: 00000000    gs: 00000033

Signed-off-by: Arun Sharma <arun.sharma@intel.com>
Signed-off-by: ian@xensource.com
.rootkeys
tools/xentrace/xenctx.c [new file with mode: 0644]
xen/arch/x86/dom0_ops.c

index 96b1c00dbf397f98f56e1a0758ea148979e29be6..c990c9d74119d57a200bb79afd62eb1736d74a77 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 41d58ba6ijEF6fedqRO5vFu7uCirZg tools/xcs/xcsdump.c
 403a3edbrr8RE34gkbR40zep98SXbg tools/xentrace/Makefile
 40a107afN60pFdURgBv9KwEzgRl5mQ tools/xentrace/formats
+420d52d2_znVbT4JAPIU36vQOme83g tools/xentrace/xenctx.c
 4050c413PhhLNAYk3TEwP37i_iLw9Q tools/xentrace/xentrace.8
 403a3edbVpV2E_wq1zeEkJ_n4Uu2eg tools/xentrace/xentrace.c
 403a3edblCUrzSj0mmKhO5HOPrOrSQ tools/xentrace/xentrace_format
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
new file mode 100644 (file)
index 0000000..4a65d53
--- /dev/null
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * tools/xentrace/xenctx.c
+ *
+ * Tool for dumping the cpu context
+ *
+ * Copyright (C) 2005 by Intel Corp
+ *
+ * Author: Arun Sharma <arun.sharma@intel.com>
+ * Date:   February 2005
+ */
+
+#include <time.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <argp.h>
+#include <signal.h>
+
+#include "xc.h"
+
+#ifdef __i386__
+void
+print_ctx(full_execution_context_t *ctx1)
+{
+    execution_context_t *ctx = &ctx1->cpu_ctxt;
+
+    printf("eip: %08lx\t", ctx->eip);
+    printf("esp: %08lx\n", ctx->esp);
+
+    printf("eax: %08lx\t", ctx->eax);
+    printf("ebx: %08lx\t", ctx->ebx);
+    printf("ecx: %08lx\t", ctx->ecx);
+    printf("edx: %08lx\n", ctx->edx);
+
+    printf("esi: %08lx\t", ctx->esi);
+    printf("edi: %08lx\t", ctx->edi);
+    printf("ebp: %08lx\n", ctx->ebp);
+
+    printf(" cs: %08lx\t", ctx->cs);
+    printf(" ds: %08lx\t", ctx->ds);
+    printf(" fs: %08lx\t", ctx->fs);
+    printf(" gs: %08lx\n", ctx->gs);
+
+}
+#endif
+
+void dump_ctx(u32 domid, u32 vcpu)
+{
+    int ret;
+    xc_domaininfo_t info;
+    full_execution_context_t ctx;
+
+    int xc_handle = xc_interface_open(); /* for accessing control interface */
+
+    ret = xc_domain_getfullinfo(xc_handle, domid, vcpu, &info, &ctx);
+    if (ret != 0) {
+        perror("xc_domain_getfullinfo");
+        exit(-1);
+    }
+    print_ctx(&ctx);
+    xc_interface_close(xc_handle);
+}
+
+int main(int argc, char **argv)
+{
+    int vcpu = 0;
+
+    if (argc < 2) {
+        printf("usage: xenctx <domid> <optional vcpu>\n");
+        exit(-1);
+    }
+
+    if (argc == 3)
+        vcpu = atoi(argv[2]);
+
+    dump_ctx(atoi(argv[1]), vcpu);
+
+    return 0;
+}
index ea4328766847aff27bbd8519b63748282ea8c47c..9e7ec8c31b73d72d22b49752f9c07c31d331ce5f 100644 (file)
@@ -348,11 +348,17 @@ void arch_getdomaininfo_ctxt(
     struct exec_domain *ed, full_execution_context_t *c)
 { 
     int i;
+    unsigned long vmx_domain = ed->arch.arch_vmx.flags;
+    extern void save_vmx_execution_context(execution_context_t *);
 
     c->flags = 0;
     memcpy(&c->cpu_ctxt, 
            &ed->arch.user_ctxt,
            sizeof(ed->arch.user_ctxt));
+
+    if (vmx_domain)
+        save_vmx_execution_context(&c->cpu_ctxt);
+
     if ( test_bit(EDF_DONEFPUINIT, &ed->ed_flags) )
         c->flags |= ECF_I387_VALID;
     if ( KERNEL_MODE(ed, &ed->arch.user_ctxt) )